﻿function displayImgs() {
    if (document.getElementById('dispImgs').checked == true) {
        document.getElementById('leftBlk').style.display = "none";
    } else {
        document.getElementById('leftBlk').style.display = "block";
    }
}

var ince = 1;
function increase() {
    var tCnt = 0;
    tCnt = document.getElementById('totCnt').innerHTML;
    if (tCnt > ince) {
        ince++;
        document.getElementById('boldstuff').innerHTML = ince;
        if (ince == tCnt) {
            document.getElementById('boldstuff').innerHTML = ince;
            ince = 0;

        }
    }

}

function decrease() {
    var tCnt = 0;
    tCnt = document.getElementById('totCnt').innerHTML;
    if (ince > 0) {
        ince--;
        document.getElementById('boldstuff').innerHTML = ince;
        if (ince < 1) {
            document.getElementById('boldstuff').innerHTML = tCnt;
            ince = tCnt;
        }
    }
}


function previewOnload() {
    document.getElementById('doingText').focus();
    $('#s2').cycle({
        fx: 'fade',
        speed: 'fast',
        timeout: 0,
        next: '#next2',
        prev: '#prev2',
        after: function (currSlideElement, nextSlideElement, options, forwardFlag) {
            $("#addLinkImgSrc").val(nextSlideElement.src);
        }   //end of after function
    });
}

function addTheme(the) {
    var postedParameters = "";
    postedParameters = "t=adThe&theme=" + the;
    $.ajax({
        type: "POST",
        url: "/AddCommForPhPrMemPh.aspx",
        data: postedParameters,
        success: function (ss) {

        }
    });

}

function promoteAd(param, proId) {
    var postedParameters = "";
    var innerDiv = "";
    postedParameters = "a=" + param + "&promotionId=" + proId;

    if (param == "T") {
        if (confirm("Are you sure you want to move this Ad to trash?")) {
            $.ajax({
                type: "POST",
                url: "/PromoteAds.aspx",
                data: postedParameters,
                success: function (respMsg) {
                    if (respMsg.length > 1) {
                        innerDiv = respMsg.substring(1);
                        respMsg = respMsg.substring(0, 1);
                        if (innerDiv != '') {
                            var html = $('#newMembers').html();
                            $('#newMembers').html(innerDiv);
                            // $('div.newMembers').html(innerDiv);
                            //document.getElementById('newMembers').innerhtml = innerDiv;
                        }
                    }
                    if (respMsg == '2') {
                        document.getElementById('deleteAd').style.display = 'none';
                    }
                }
            });
            return false;
        }
        return false;
    } else {
        $.ajax({
            type: "POST",
            url: "/PromoteAds.aspx",
            data: postedParameters,
            success: function (respMsg) {
                if (respMsg.length > 1) {
                    innerDiv = respMsg.substring(1);
                    respMsg = respMsg.substring(0, 1);
                    if (innerDiv != '') {
                        var html = $('#newMembers').html();
                        $('#newMembers').html(innerDiv);
                        // $('div.newMembers').html(innerDiv);
                        //document.getElementById('newMembers').innerhtml = innerDiv;
                    }
                }
                if (respMsg == '0') {
                    document.getElementById('unlikePro').style.display = 'block';
                    document.getElementById('likePro').style.display = 'none';
                }
                if (respMsg == '1') {
                    document.getElementById('unlikePro').style.display = 'none';
                    document.getElementById('likePro').style.display = 'block';
                }

            }
        });

    }
}


function initEmbedly() {

    $("span.updatesText a[href!='#']").embedly({
        maxWidth: 390,
        maxHeight: 360,
        wmode: 'transparent',
        key: '9471d00cfdcf11df84894040444cdc60'
    }, function (oembed, dict) {
        if (oembed == null)
            return false;
        else {
            var destCode = "<div class='ytHolder'>";
            if (oembed.type == "video") {
                destCode += "<a href='#'>";
                destCode += "<img src='/ProcessExternalThumbnails.aspx?ThumbUrl=" + oembed.thumbnail_url + "' />";
                destCode += "<div class='ytVidArrow'></div>";
                destCode += "<span class='ytTitle'>" + oembed.title + "</span>";
                destCode += "</a>";

                destCode += "<div class='ytHiddenCode' style='display: none;'>";
                destCode += oembed.code;
                destCode += "</div>";
            } else if (oembed.type == "photo") {
                var tmpNode = $(document.createElement("div"));
                $(tmpNode).html(oembed.code);

                destCode += "<a target='_blank' href='" + $(tmpNode).find("div.embed").children("a").attr("href") + "'>";
                destCode += "<img src='/ProcessExternalThumbnails.aspx?ThumbUrl=" + oembed.thumbnail_url + "' />";
                destCode += "<span class='ytTitle'>" + oembed.title + "</span>";
                destCode += "</a>";

                $(tmpNode).remove();

                //alert(oembed.code);
            } else {
                destCode += oembed.code;
                destCode += "<span class='ytTitle'>" + oembed.title + "</span>";
            }

            destCode += "</div><br/>";

            var parNode = $(dict["node"]).parent();
            $(parNode).html(destCode);

            if (oembed.type == "video") {
                $(parNode).children("div.ytHolder").children("a").click(function (e) {
                    e.preventDefault();
                    $(this).parent().children(".ytHiddenCode").show();
                    $(this).remove();
                });
            } else if (oembed.type != "photo") {
                $(parNode).find("a").attr("target", "_blank");
            }

        }
    });

}
// end of initEmbedly

var ckBt = 0;

function validText() {

    ckBt += 1;
    if (document.getElementById('doingText').value == '') {
        alert('Please provide text.');
        return false;
    }

    var ele = document.getElementById("maskL");
    if (ele.style.display == "block") {
        ele.style.display = "none";
    }
    var ele = document.getElementById("maskP");
    if (ele.style.display == "block") {
        ele.style.display = "none";
    }
    var ele = document.getElementById("maskV");
    if (ele.style.display == "block") {
        ele.style.display = "none";
    }
    var ele = document.getElementById("maskV2");
    if (ele.style.display == "block") {
        ele.style.display = "none";
    }

    // set active icons
    var ele = document.getElementById("av");
    if (ele.style.display == "block") {
        ele.style.display = "none";
    }
    var ele = document.getElementById("nv");
    if (ele.style.display == "none") {
        ele.style.display = "block";
    }

    var ele = document.getElementById("ap");
    if (ele.style.display == "block") {
        ele.style.display = "none";
    }
    var ele = document.getElementById("np");
    if (ele.style.display == "none") {
        ele.style.display = "block";
    }

    var ele = document.getElementById("al");
    if (ele.style.display == "block") {
        ele.style.display = "none";
    }
    var ele = document.getElementById("nl");
    if (ele.style.display == "none") {
        ele.style.display = "block";
    }

}

function loadNextData(moreBtn) {
    $(moreBtn).parent().append("<div style='position:relative; top: -25px; left: 280px; background-color: transparent;'><img src='/i/loadingIcon-sprite-square.gif' alt='Loading...' /></div>");
    $(moreBtn).parent().append("<div class='LoadMore'></div>");
    $(moreBtn).parent().load("/showUpdates.aspx?ckBt=" + ckBt + '&' + $(moreBtn).attr("qryParams") + "", function () {
        if ($("div.msg_list").children("div.msg_body").children("div.commentpost").length > 3) {
            $("div.msg_list").children("div.msg_body").children("div.commentpost").hide();
            $("div.msg_list").children("div.msg_body").children("div.commentpost:nth-child(1)").show();
            $("div.msg_list").children("div.msg_body").children("div.commentpost:nth-child(2)").show();
            $("div.msg_list").children("div.msg_body").children("div.commentpost:nth-child(3)").show();

            $("div.msg_list").children("span.msg_head").click(function (ev) {
                $(this).parent().find("div.msg_body").children("div.commentpost:hidden").slideDown("slow");
                $(this).slideUp("slow", function () { $(this).remove(); });
            });
            $(".tipped").each(function () {
                Tipped.create(this, "/AutoNames.aspx", {
                    type: "post",
                    cache: true,
                    ajax: {
                        data: { a: $(this).attr("tipP"), mId: $(this).attr("mId") }
                    }
                });
            });


        }
        InitJQuery();
    });

}

function showCommentDiv(i) {
    $("div#" + i.toString()).find("div.CommentsWrap:hidden").slideToggle('slow');
    if (document.getElementById("groupComm" + i).style.display == "none") {
        document.getElementById("groupComm" + i).style.display = "block";
        document.getElementById("groupComment" + i).focus();
    } else if (document.getElementById("groupComm" + i).style.display == "block") {
        document.getElementById("groupComm" + i).style.display = "none";
    }
}

function limitText(limitField, limitNum) {
    if (limitField.value.length > limitNum) {
        limitField.value = limitField.value.substring(0, limitNum);
    }
}

function delCommentForAll(param, gcId, memId, owId, i) {
    var str2;
    if ((param == 'stf') || (param == 'af') || (param == 'fsnp') || (param == 'fpg')) {
        str2 = 'Are you sure you want to delete this from favorites?';
    } else if ((param == 'albSng') || (param == 'doSng') || (param == 'phSng') || (param == 'pgSng')) {
        str2 = 'Are you sure you want to hide this post?';
    } else {
        str2 = 'Are you sure you want to delete this comment?';
    }
    if (confirm(str2)) {
        $('#load').fadeIn();
        var string;
        if (param == 'pgSng') {
            string = 't=' + param + '&wallPostingId=' + gcId + '&memberId=' + memId + '&pgId=' + owId;
        }
        else {
            string = 't=' + param + '&groupCommentId=' + gcId + '&memberId=' + memId + '&owId=' + owId;
        }
        $.ajax({
            type: "POST",
            url: "/DeleteCommForPhPrMemPh.aspx",
            data: string,
            cache: false,
            success: function () {
                if (param == 'phSng') {
                    $("#" + i).slideToggle("normal");
                    document.getElementById('undoDisp' + i).innerHTML = "<p>Post Hidden from your News Feed. <a onclick='undoOptFrPh(" + gcId + "," + memId + "," + owId + "," + i + ");'>Undo</a></p>";
                } else if (param == 'doSng') {
                    $("#" + i).slideToggle("normal");
                    document.getElementById('undoDisp' + i).innerHTML = "<p>Post Hidden from your News Feed. <a onclick='undoOpt(" + gcId + "," + memId + "," + owId + "," + i + ");'>Undo</a></p>";
                } else if (param == 'albSng') {
                    $("#" + i).slideToggle("normal");
                    document.getElementById('undoDisp' + i).innerHTML = "<p>Post Hidden from your News Feed. <a onclick='undoOpt(" + gcId + "," + memId + "," + owId + "," + i + ");'>Undo</a></p>";
                } else if (param == 'pgSng') {
                    $("#" + i + owId).slideToggle("normal");
                    document.getElementById('undoDisp' + i).innerHTML = "<p>Post Hidden from your News Feed. <a onclick='undoOptFrPage(" + gcId + "," + memId + "," + owId + "," + i + ");'>Undo</a></p>";
                }
                else if ((param == 'dpru') || (param == 'siud')) {
                    var commentContainer = $("#comm" + gcId);
                    commentContainer.slideUp('slow', function () { $("#comm" + gcId).remove(); });
                }
                else {
                    var commentContainer = $("#" + i);
                    commentContainer.slideUp('slow', function () { $("#" + i).remove(); });
                }
                $('#load').fadeOut();
            }
        });
        return false;
    }
    return false;
}

function undoOptFrPh(gcId, memId, albId, i) {

    var postedParameters = "";
    postedParameters = 'i=' + i.toString() + '&t=phSng&groupCommentId=' + gcId + '&owId=' + albId + '&memberId=' + memId;
    $.ajax({
        type: "POST",
        url: "/AddCommForPhPrMemPh.aspx",
        data: postedParameters,
        success: function (respMsg) {
            document.getElementById('undoDisp' + i).innerHTML = "";
            $("#" + i).slideToggle("normal");
        }
    });

}


function undoOptFrPage(gcId, memId, pgId, i) {

    var postedParameters = "";
    postedParameters = 'i=' + i.toString() + '&t=pgSng&wallPostingId=' + gcId + '&pgId=' + pgId + '&memberId=' + memId;
    $.ajax({
        type: "POST",
        url: "/AddCommForPhPrMemPh.aspx",
        data: postedParameters,
        success: function (respMsg) {
            document.getElementById('undoDisp' + i).innerHTML = "";
            $("#" + i + pgId).slideToggle("normal");
        }
    });

}


function undoOpt(gcId, memId, albId, i) {

    var postedParameters = "";
    postedParameters = 'i=' + i.toString() + '&t=undo&groupCommentId=' + gcId + '&owId=' + albId + '&memberId=' + memId + "&" + $("#albHide" + i.toString()).attr("postParameters");
    $.ajax({
        type: "POST",
        url: "/AddCommForPhPrMemPh.aspx",
        data: postedParameters,
        success: function (respMsg) {
            document.getElementById('undoDisp' + i).innerHTML = "";
            $("#" + i).slideToggle("normal");
        }
    });

}


function formSubmit(str2) {
    window.location = "search.aspx?dList=ure&strSearch=" + str2;
}

function LikeForAllUpd(param, w) {
    var postedParameters = "";
    postedParameters = "t=" + param + "&w=" + w.toString() + "&" + $("#groupLike" + w.toString()).attr("postParameters");
    $.ajax({
        type: "POST",
        url: "/LikeForAllUpdates.aspx",
        data: postedParameters,
        success: function (respMsg) {
            if ($("div#" + w.toString()).find("a#groupLike" + w.toString()).text().toLowerCase() == "like") {
                $("div#" + w.toString()).find("a#groupLike" + w.toString()).text("Unlike");
            }
            else {
                $("div#" + w.toString()).find("a#groupLike" + w.toString()).text("Like");
            }
            $("div#" + w.toString()).find("div.CommentsWrap").find("div.Likes").remove();
            $("div#" + w.toString()).find("div.CommentsWrap").find("div.Iw").prepend(respMsg);
            $("div#" + w.toString()).find("div.CommentsWrap:hidden").slideToggle('slow');
        }
    });

}




function FaveForAllUpd(param, w) {
    // $(this).parent().remove();
    var postedParameters = "";
    postedParameters = "t=" + param + "&w=" + w.toString() + "&" + $("#faveUpd" + w.toString()).attr("postParameters");
    $.ajax({
        type: "POST",
        url: "/LikeForAllUpdates.aspx",
        data: postedParameters,
        success: function (respMsg) {
            var divClassName = "";
            divClassName = "faveU" + w.toString();
            if ($("#" + divClassName).text() != '') {
                $("#" + divClassName).text('');
                // $("#" + divClassName).append(respMsg);
            }
            else {
                //$("#" + divClassName).append(respMsg);
            }

            //   runEffect();

            $("div#effect").css("display", "block");
            $("div#effect").slideDown("slow");
            // $("div#effect").css("display", "none");

            //  $("div#effect").html("");

        }
    });

}

function delCommentOfPost(commentId) {
    if (confirm("Are you sure you want to delete this comment?")) {
        $('#load').fadeIn();
        var commentContainer = $("#comm" + commentId);
        var string = 'a=delPostCmt&commentId=' + commentId;
        $.ajax({
            type: "POST",
            url: "/JqueryPageGroup.aspx",
            data: string,
            cache: false,
            success: function () {
                commentContainer.slideUp('slow', function () { $("#comm" + commentId).remove(); });
                $('#load').fadeOut();
            }
        });
        return false;
    }
    return false;
}
function saveCommentForAll(i, param) {
    if (document.getElementById("groupComment" + i).value == '') {
        alert('Please provide Comment.');
        return false;
    } else {

        var postedParameters = "";
        postedParameters = "t=" + param + "&fCommentMsg=" + encodeURIComponent(document.getElementById("groupComment" + i).value) + "&" + $("#groupComment" + i.toString()).attr("postParameters");
        $.ajax({
            type: "POST",
            url: "/AddCommForPhPrMemPh.aspx",
            data: postedParameters,
            success: function (respMsg) {

                $("div#" + i.toString()).find("div.write-comment").before(respMsg);
                $("div#" + i.toString()).find("div.CommentsWrap:hidden").slideToggle('slow');
            }
        });
        document.getElementById('groupComment' + i.toString()).value = "";
    }
}

function delCommentOfAlbum(param, commentId, memId, wpId) {
    if (confirm("Are you sure you want to delete this comment?")) {
        $('#load').fadeIn();
        var commentContainer = $("#comm" + commentId + memId + wpId);
        var string = 'a=' + param + '&commentId=' + commentId;
        $.ajax({
            type: "POST",
            url: "/JqueryPageGroup.aspx",
            data: string,
            cache: false,
            success: function () {
                commentContainer.slideUp('slow', function () { $("#commA" + commentId + memId + wpId).remove(); });
                $('#load').fadeOut();
            }
        });
        return false;
    }
    return false;
}

function deleteMainComment(w, memberId, doingId, param) {
    if (confirm("Are you sure you want to delete this comment?")) {
        $('#load').fadeIn();
        var commentContainer = $("#" + w);
        var string = 'p=' + param + '&memberId=' + memberId + '&doingId=' + doingId;
        $.ajax({
            type: "POST",
            url: "/DeleteMyUpdates.aspx",
            data: string,
            cache: false,
            success: function () {
                commentContainer.slideUp('slow', function () { $("#" + w).remove(); });
                $('#load').fadeOut();
            }
        });
        return false;
    }
    return false;
}

function shareMsgpg(ipBtn) {
    var dataToPost;
    dataToPost = {
        memberId: $("#ShareUpdDlg").find("#memId").val(),
        iValD: $("#ShareUpdDlg").find("#iValD").val(),
        pgId: $("#ShareUpdDlg").find("#pgId").val(),
        wallPostingId: $("#ShareUpdDlg").find("#wallPostingId").val(),
        newText: $("#ShareUpdDlg").find("#newText").val(),
        post: $("#ShareUpdDlg").find("#newText").val(),
        parm: $("#ShareUpdDlg").find("#parm").val(),
        listFr: $("#ShareUpdDlg").find("#listFr").val(),
        toWhom: $("#ShareUpdDlg").find("#speedCDup2A").val()
    };
    $.ajax({
        type: "POST",
        url: "popupShare.aspx",
        async: true,
        data: dataToPost,
        success: function (respData, textStatus, jqXHR) {
            $("#ShareUpdDlg").dialog('close');
        },
        error: function (jqXHR, textStatus, errorThrown) {
            alert("Error processing" + errorThrown);
        }
    });
}


function shareMessage(ipBtn) {
    var dataToPost;
    if ($("#ShareUpdDlg").find("#speedCDup").val() == 'cm') {
        if ($("#ShareUpdDlg").find("#tokenize2").val() == '') {
            alert('Please select hide from these people.');
            return false;
        }
        if ($("#ShareUpdDlg").find("#showToPeople").val() == '') {
            alert('Please select show to these people.');
            return false;
        }
    }
    dataToPost = {
        speedC: $("#ShareUpdDlg").find("#speedCDup").val(),
        tokenize2: $("#ShareUpdDlg").find("#tokenize2").val(),
        showToPeople: $("#ShareUpdDlg").find("#showToPeople").val(),
        updateOwner: $("#ShareUpdDlg").find("#updateOwner").val(),
        doId: $("#ShareUpdDlg").find("#oldId").val(),
        newText: $("#ShareUpdDlg").find("#newText").val(),
        listFr: $("#ShareUpdDlg").find("#listFr").val(),
        toWhom: $("#ShareUpdDlg").find("#speedCDup2A").val(),
        parm: $("#ShareUpdDlg").find("#parm").val()
    };

    $.ajax({
        type: "POST",
        url: "popupShare.aspx",
        async: true,
        data: dataToPost,
        success: function (respData, textStatus, jqXHR) {
            $("#ShareUpdDlg").dialog('close');
        },
        error: function (jqXHR, textStatus, errorThrown) {
            alert("Error processing" + errorThrown);
        }
    });
}

function editUpd(ipBtn) {
    var dataToPost;
    dataToPost = {
        doingText: $("#edtUpdDlg").find("#newText").val(),
        doId: $("#edtUpdDlg").find("#oldId").val(),
        parm: $("#edtUpdDlg").find("#parm").val(),
        speedC: $("#edtUpdDlg").find("#speedCDup").val(),
        iValD: $("#edtUpdDlg").find("#iValD").val(),
        edttokenize2: $("#edtUpdDlg").find("#edttokenize2").val(),
        edtshowToPeople: $("#edtUpdDlg").find("#edtshowToPeople").val()
    };



    $.ajax({
        type: "POST",
        url: "popupShare.aspx",
        async: true,
        data: dataToPost,
        success: function (respData, textStatus, jqXHR) {
            $("#edtUpdDlg").dialog('close');
            var parentblockid = $('[mainpageblockid]').attr("mainpageblockid");
            $("#" + parentblockid).html(respData);
            document.getElementById('edtUpdDlg').innerHTML = '';
        },
        error: function (jqXHR, textStatus, errorThrown) {
            alert("Error processing " + errorThrown);
        }
    });
}


function jqModal(jqPrm) {
    $("#resUpdDlg").dialog('open');

    var string = 'uId=0&a=' + $(jqPrm).attr("parm") + '&doId=' + $(jqPrm).attr("id");
    $.ajax({
        type: "POST",
        url: "/AutoNames.aspx",
        data: string,
        success: function (respMsg) {
            $("#resUpdDlg").html(respMsg);
        }
    });

}
function sharePg(pbtn) {
    $("#ShareUpdDlg").html($(pbtn).parents("div.block-post").clone().html());

    $("#ShareUpdDlg").find("div.status").remove();
    //$("#testDlg").find("div.userDetails").attr("style", "border:0px;");

    var cmbDivShow = $("<div class='GrpCmbShow'></div>");

    $(cmbDivShow).append("<div class='ShareContentPrv'><div class='WriteTxt'><textarea name='newText' onKeyDown='limitText(newText,2048);' onKeyUp='limitText(newText,2048);' id='newText' maxlength='2048'></textarea></div></div>");
    $(cmbDivShow).append("<input type='button' class='button' value='Share' onclick='shareMsgpg(this)'/>");
    $(cmbDivShow).append("<input type='hidden' name='iValD' id='iValD' value='" + $(pbtn).attr("iValD") + "' />");
    $(cmbDivShow).append("<input type='hidden' name='parm' id='parm' value='" + $(pbtn).attr("parm") + "' />");
    $(cmbDivShow).append("<input type='hidden' name='memId' id='memId' value='" + $(pbtn).attr("updOwnerId") + "' />");
    $(cmbDivShow).append("<input type='hidden' name='wallPostingId' id='wallPostingId' value='" + $(pbtn).attr("doId") + "' />");
    $(cmbDivShow).append("<input type='hidden' name='pgId' id='pgId' value='" + $(pbtn).attr("pgId") + "' />");
    $(cmbDivShow).append("<div class='LAlign'><h3>Share : </h3><select style='width:150px;' name='speedCDup2A' id='speedCDup2A' onchange='frndwallFrPg();'><option value='ne'>[Select One]</option><option value='ow'>On your own wall</option><option value='fsw'>On friend's wall</option></select></div>");

    $(cmbDivShow).append("<div class='updateCz' id='updateCzA2' style='display:none;'><div class='show-hide'><ul><li><span>Type a friend's name : </span><input type='text' name='listFr' id='listFr' /></li></ul></div></div>");

    $("#ShareUpdDlg").append($(cmbDivShow));
    $("#ShareUpdDlg #speedCDup2A").selectmenu();
    $("#ShareUpdDlg").dialog('open');

    $("span.ui-icon.ui-icon-closethick").text('');

    $("#ShareUpdDlg").find("#listFr").tokenInput("cntFriends.aspx", {
        classes: {
            tokenList: "token-input-list-facebook",
            token: "token-input-token-facebook",
            tokenDelete: "token-input-delete-token-facebook",
            selectedToken: "token-input-selected-token-facebook",
            highlightedToken: "token-input-highlighted-token-facebook",
            dropdown: "token-input-dropdown-facebook",
            dropdownItem: "token-input-dropdown-item-facebook",
            dropdownItem2: "token-input-dropdown-item2-facebook",
            selectedDropdownItem: "token-input-selected-dropdown-item-facebook",
            inputToken: "token-input-input-token-facebook"
        }
    });
}

function frndwallFrPg() {
    if (document.getElementById("speedCDup2A").value == "fsw") {
        if (document.getElementById("updateCzA2").style.display == "none") {
            document.getElementById("updateCzA2").style.display = "block";
        }
    } else {
        document.getElementById("updateCzA2").style.display = "none";
    }
}

function frndwall() {
    if (document.getElementById("speedCDup2A").value == "fsw") {
        if (document.getElementById("updateCzA2").style.display == "none") {
            document.getElementById("updateCzA2").style.display = "block";
        }
        if ((document.getElementById("sdShHd").style.display == "block") || (document.getElementById("sdShHd").style.display == "")) {
            document.getElementById("sdShHd").style.display = "none";
        }
        if (document.getElementById("HidwDD").style.display == "block") {
            document.getElementById("HidwDD").style.display = "none";
        }

    } else {
        document.getElementById("sdShHd").style.display = "none";
        document.getElementById("updateCzA2").style.display = "none";
        document.getElementById("HidwDD").style.display = "block";
    }
}
function shareM(pbtn) {
    $("#ShareUpdDlg").html($(pbtn).parents("div.block-post").clone().html());
    $("#ShareUpdDlg").find("div.status").remove();
    //$("#testDlg").find("div.userDetails").attr("style", "border:0px;");
    var cmbDivShow = $("<div class='GrpCmbShow'></div>");

    $(cmbDivShow).append("<div class='ShareContentPrv'><div class='WriteTxt'><textarea name='newText' onKeyDown='limitText(newText,2048);' onKeyUp='limitText(newText,2048);' id='newText' maxlength='2048'></textarea></div></div>");
    $(cmbDivShow).append("<input type='button' class='button' value='Share' onclick='shareMessage(this)'/>");
    $(cmbDivShow).append("<input type='hidden' name='updateOwner' id='updateOwner' value='" + $(pbtn).attr("updOwnerId") + "' />");
    $(cmbDivShow).append("<input type='hidden' name='parm' id='parm' value='" + $(pbtn).attr("parm") + "' />");

    $(cmbDivShow).append("<input type='hidden' name='oldId' id='oldId' value='" + $(pbtn).attr("doId") + "' />");

    $(cmbDivShow).append("<div class='LAlign'><h3>Share : </h3><select style='width:150px;' name='speedCDup2A' id='speedCDup2A' onchange='frndwall();'><option value='ow'>On your own wall</option><option value='fsw'>On friend's wall</option></select></div>");

    $(cmbDivShow).append("<div id='HidwDD' style='display:block;'><select id='speedCDup' name='speedCDup' style='width:90px;height:120px;'>" + $("#speedC").clone().html() + "</select></div>");

    $(cmbDivShow).append("<div class='updateCz' id='updateCzA2' style='display:none;'><div class='show-hide'><ul><li><span>Type a friend's name : </span><input type='text' name='listFr' id='listFr' /></li></ul></div></div>");
    $(cmbDivShow).append("<div class='updateCz' id='sdShHd' style='display:none;'><div  class='show-hide'><ul><li><span>Hide from these people:</span> <input type='text'  name='tokenize2' id='tokenize2'/></li><li><span>Show to these people:</span><input type='text' name='showToPeople' id='showToPeople'/></li></ul></div></div>");

    $("#ShareUpdDlg").append($(cmbDivShow));

    $("#ShareUpdDlg #speedCDup").selectmenu();
    $("#ShareUpdDlg #speedCDup2A").selectmenu();

    $("#ShareUpdDlg").find("#listFr").tokenInput("cntFriends.aspx", {
        classes: {
            tokenList: "token-input-list-facebook",
            token: "token-input-token-facebook",
            tokenDelete: "token-input-delete-token-facebook",
            selectedToken: "token-input-selected-token-facebook",
            highlightedToken: "token-input-highlighted-token-facebook",
            dropdown: "token-input-dropdown-facebook",
            dropdownItem: "token-input-dropdown-item-facebook",
            dropdownItem2: "token-input-dropdown-item2-facebook",
            selectedDropdownItem: "token-input-selected-dropdown-item-facebook",
            inputToken: "token-input-input-token-facebook"
        }
    });

    $("#ShareUpdDlg").find("#tokenize2").tokenInput("cntFriends.aspx", {
        classes: {
            tokenList: "token-input-list-facebook",
            token: "token-input-token-facebook",
            tokenDelete: "token-input-delete-token-facebook",
            selectedToken: "token-input-selected-token-facebook",
            highlightedToken: "token-input-highlighted-token-facebook",
            dropdown: "token-input-dropdown-facebook",
            dropdownItem: "token-input-dropdown-item-facebook",
            dropdownItem2: "token-input-dropdown-item2-facebook",
            selectedDropdownItem: "token-input-selected-dropdown-item-facebook",
            inputToken: "token-input-input-token-facebook"
        }
    });

    $("#ShareUpdDlg").find("#showToPeople").tokenInput("cntFriends.aspx", {
        classes: {
            tokenList: "token-input-list-facebook",
            token: "token-input-token-facebook",
            tokenDelete: "token-input-delete-token-facebook",
            selectedToken: "token-input-selected-token-facebook",
            highlightedToken: "token-input-highlighted-token-facebook",
            dropdown: "token-input-dropdown-facebook",
            dropdownItem: "token-input-dropdown-item-facebook",
            dropdownItem2: "token-input-dropdown-item2-facebook",
            selectedDropdownItem: "token-input-selected-dropdown-item-facebook",
            inputToken: "token-input-input-token-facebook"
        }
    });


    $("#ShareUpdDlg").dialog('open');

    $("span.ui-icon.ui-icon-closethick").text('');

    $("#ShareUpdDlg #speedCDup").change(function () {
        if ($(this).val() == "cm")
            $("#ShareUpdDlg #sdShHd").show();
        else
            $("#ShareUpdDlg #sdShHd").hide();
    });

    return false;

}

function editOp(allp) {
    $("#edtUpdDlg").dialog('open');

    var cmbDivShow = $("<div class='GrpCmbShow' mainpageblockid='" + $(allp).attr("ivald") + "'></div>");
    $(cmbDivShow).append("<input type='hidden' name='parm' id='parm' value='" + $(allp).attr("parm") + "' />");

    $(cmbDivShow).append("<input type='hidden' name='oldId' id='oldId' value='" + $(allp).attr("doId") + "' />");
    $(cmbDivShow).append("<input type='hidden' name='iValD' id='iValD' value='" + $(allp).attr("iValD") + "' />");

    $(cmbDivShow).append("<div class='ShareContentPrv'><div class='WriteTxt'><textarea maxlength='2048' onKeyDown='limitText(newText,2048);' onKeyUp='limitText(newText,2048);' name='newText' id='newText'>" + $(allp).attr("doiTxt") + "</textarea></div></div>");
    var om1, fr1, cm1, eo1, fo1;
    if ($.trim($(allp).attr('forWm')) == 'om') {
        om1 = "selected='selected'";
    } else if ($.trim($(allp).attr('forWm')) == 'fr') {
        fr1 = "selected='selected'";
    } else if ($.trim($(allp).attr('forWm')) == 'cm') {
        cm1 = "selected='selected'";
    } else if ($.trim($(allp).attr('forWm')) == 'eo') {
        eo1 = "selected='selected'";
    } else if ($.trim($(allp).attr('forWm')) == 'fo') {
        fo1 = "selected='selected'";
    }
    $(cmbDivShow).append("<div id='HidwDD' style='display:block;'><select id='speedCDup' name='speedCDup' style='width:90px;height:120px;'><option value ='eo'" + eo1 + ">Everyone</option><option value ='fr'" + fr1 + ">Friends</option><option value ='fo'" + fo1 + ">Followers</option><option value ='om'" + om1 + ">Only Me</option><option value ='cm'" + cm1 + ">Customize</option></select></div>");
    if ($.trim($(this).attr('forWm')) == 'cm') {
        $(cmbDivShow).append("<div class='updateCz' id='sdShHd' style='display:block;'><div  class='show-hide'><ul><li><span>Hide from these people:</span> <input type='text'  name='edttokenize2' id='edttokenize2'/></li><li><span>Show to these people:</span><input type='text' name='edtshowToPeople' id='edtshowToPeople'/></li></ul></div></div>");
    } else {
        $(cmbDivShow).append("<div class='updateCz' id='sdShHd' style='display:none;'><div  class='show-hide'><ul><li><span>Hide from these people:</span> <input type='text'  name='edttokenize2' id='edttokenize2'/></li><li><span>Show to these people:</span><input type='text' name='edtshowToPeople' id='edtshowToPeople'/></li></ul></div></div>");
    }
    $(cmbDivShow).append("<input type='button' class='button' value='Edit' onclick='editUpd(this)'/>");

    $("#edtUpdDlg").append($(cmbDivShow));
    $("#edtUpdDlg #speedCDup").selectmenu();

    $("#edtUpdDlg").find("#edttokenize2").tokenInput("cntFriends.aspx", {
        classes: {
            tokenList: "token-input-list-facebook",
            token: "token-input-token-facebook",
            tokenDelete: "token-input-delete-token-facebook",
            selectedToken: "token-input-selected-token-facebook",
            highlightedToken: "token-input-highlighted-token-facebook",
            dropdown: "token-input-dropdown-facebook",
            dropdownItem: "token-input-dropdown-item-facebook",
            dropdownItem2: "token-input-dropdown-item2-facebook",
            selectedDropdownItem: "token-input-selected-dropdown-item-facebook",
            inputToken: "token-input-input-token-facebook"
        }
    });

    $("#edtUpdDlg").find("#edtshowToPeople").tokenInput("cntFriends.aspx", {
        classes: {
            tokenList: "token-input-list-facebook",
            token: "token-input-token-facebook",
            tokenDelete: "token-input-delete-token-facebook",
            selectedToken: "token-input-selected-token-facebook",
            highlightedToken: "token-input-highlighted-token-facebook",
            dropdown: "token-input-dropdown-facebook",
            dropdownItem: "token-input-dropdown-item-facebook",
            dropdownItem2: "token-input-dropdown-item2-facebook",
            selectedDropdownItem: "token-input-selected-dropdown-item-facebook",
            inputToken: "token-input-input-token-facebook"
        }
    });
    $("#edtUpdDlg").dialog('open');

    $("span.ui-icon.ui-icon-closethick").text('');

    $("#edtUpdDlg #speedCDup").change(function () {
        if ($(this).val() == "cm")
            $("#edtUpdDlg #sdShHd").show();
        else
            $("#edtUpdDlg #sdShHd").hide();
    });

    return false;
}


function selectFriends() {

    if (document.getElementById("speedC").value == "cm") {
        if (document.getElementById("updateCz").style.display == "none") {
            //  document.getElementById("Label1").innerHTML = '';
            document.getElementById("updateCz").style.display = "block";
        }
    } else {
        document.getElementById("updateCz").style.display = "none";
    }
}


function openUpdates() {
    var ele = document.getElementById("updatesSubs");
    if (ele.style.display == "none") {
        ele.style.display = "block";
    }
    var ele1 = document.getElementById("updatesLink");
    if (ele1.style.display == "block") {
        ele1.style.display = "none";
    }
    var ele2 = document.getElementById("PhotosubsLink");
    if (ele2.style.display == "none") {
        ele2.style.display = "block";
    }
    var ele3 = document.getElementById("PhotoSubs");
    if (ele3.style.display == "block") {
        ele3.style.display = "none";
    }
    var ele4 = document.getElementById("PagesubsLink");
    if (ele4.style.display == "none") {
        ele4.style.display = "block";
    }
    var ele5 = document.getElementById("PageSubs");
    if (ele5.style.display == "block") {
        ele5.style.display = "none";
    }
}

function closeUpdates() {
    var ele4 = document.getElementById("updatesSubs");
    if (ele4.style.display == "block") {
        ele4.style.display = "none";
    }
    var ele5 = document.getElementById("updatesLink");
    if (ele5.style.display == "none") {
        ele5.style.display = "block";
    }

}

/***/


function openPhotosubs() {
    var ele = document.getElementById("PhotoSubs");
    if (ele.style.display == "none") {
        ele.style.display = "block";
    }
    var ele = document.getElementById("PhotosubsLink");
    if (ele.style.display == "block") {
        ele.style.display = "none";
    }
    var ele = document.getElementById("updatesSubs");
    if (ele.style.display == "block") {
        ele.style.display = "none";
    }
    var ele = document.getElementById("updatesLink");
    if (ele.style.display == "none") {
        ele.style.display = "block";
    }
    var ele = document.getElementById("PageSubs");
    if (ele.style.display == "block") {
        ele.style.display = "none";
    }
    var ele = document.getElementById("PagesubsLink");
    if (ele.style.display == "none") {
        ele.style.display = "block";
    }

}

function closePhotosubs() {
    var ele = document.getElementById("PhotoSubs");
    if (ele.style.display == "block") {
        ele.style.display = "none";
    }
    var ele = document.getElementById("PhotosubsLink");
    if (ele.style.display == "none") {
        ele.style.display = "block";
    }
}

function openPagesubs() {
    var ele = document.getElementById("PageSubs");
    if (ele.style.display == "none") {
        ele.style.display = "block";
    }
    var ele = document.getElementById("PagesubsLink");
    if (ele.style.display == "block") {
        ele.style.display = "none";
    }
    var ele = document.getElementById("updatesSubs");
    if (ele.style.display == "block") {
        ele.style.display = "none";
    }
    var ele = document.getElementById("updatesLink");
    if (ele.style.display == "none") {
        ele.style.display = "block";
    }

    var ele2 = document.getElementById("PhotosubsLink");
    if (ele2.style.display == "none") {
        ele2.style.display = "block";
    }
    var ele3 = document.getElementById("PhotoSubs");
    if (ele3.style.display == "block") {
        ele3.style.display = "none";
    }

}


function closePagesubs() {
    var ele = document.getElementById("PageSubs");
    if (ele.style.display == "block") {
        ele.style.display = "none";
    }
    var ele = document.getElementById("PagesubsLink");
    if (ele.style.display == "none") {
        ele.style.display = "block";
    }
}

function showShareOptions(ShareControls) {
    if (document.getElementById(ShareControls).style.display == 'none') {
        document.getElementById(ShareControls).style.display = 'block';
    }

}


function hidembS() {
    var ele = document.getElementById("hidembS");
    if (ele.style.display == "block") {
        ele.style.display = "none";
    }
    var ele1 = document.getElementById("hidewaS");
    if (ele1.style.display == "none") {
        ele1.style.display = "block";
    }
}

function hidewaS() {
    var ele = document.getElementById("hidewaS");
    if (ele.style.display == "block") {
        ele.style.display = "none";
    }
}

function openaddPic() {
    var ele = document.getElementById("addPicfield");
    if (ele.style.display == "none") {
        ele.style.display = "block";
    }
    var ele = document.getElementById("maskP");
    if (ele.style.display == "none") {
        ele.style.display = "block";
    }

    var ele = document.getElementById("ShareControls");
    if (ele.style.display == "none") {
        ele.style.display = "block";
    }
    var ele = document.getElementById("AddPhotoOptions");
    if (ele.style.display == "block") {
        ele.style.display = "none";
    }
    var ele = document.getElementById("np");
    if (ele.style.display == "block") {
        ele.style.display = "none";
    }
    var ele = document.getElementById("ap");
    if (ele.style.display == "none") {
        ele.style.display = "block";
    }


    var ele = document.getElementById("norA");
    if (ele.style.display == "block") {
        ele.style.display = "none";
    }
    var ele = document.getElementById("actA");
    if (ele.style.display == "none") {
        ele.style.display = "block";
    }


}

function closeaddPic() {
    var ele = document.getElementById("addPicfield");
    if (ele.style.display == "block") {
        ele.style.display = "none";
    }
    var ele = document.getElementById("maskP");
    if (ele.style.display == "block") {
        ele.style.display = "none";
    }

    var ele = document.getElementById("np");
    if (ele.style.display == "none") {
        ele.style.display = "block";
    }
    var ele = document.getElementById("ap");
    if (ele.style.display == "block") {
        ele.style.display = "none";
    }

    var ele = document.getElementById("norA");
    if (ele.style.display == "none") {
        ele.style.display = "block";
    }
    var ele = document.getElementById("actA");
    if (ele.style.display == "block") {
        ele.style.display = "none";
    }


}

function openaddVideo() {
    var ele = document.getElementById("nv");
    if (ele.style.display == "block") {
        ele.style.display = "none";
    }
    var ele = document.getElementById("av");
    if (ele.style.display == "none") {
        ele.style.display = "block";
    }

    var ele = document.getElementById("ShareControls");
    if (ele.style.display == "none") {
        ele.style.display = "block";
    }
    var ele = document.getElementById("maskV");
    if (ele.style.display == "none") {
        ele.style.display = "block";
    }
    var ele = document.getElementById("maskV2");
    if (ele.style.display == "none") {
        ele.style.display = "block";
    }

    var ele = document.getElementById("addVideofield");
    if (ele.style.display == "none") {
        ele.style.display = "block";
    }

    // Change textarea

    var ele = document.getElementById("norA");
    if (ele.style.display == "block") {
        ele.style.display = "none";
    }
    var ele = document.getElementById("actA");
    if (ele.style.display == "none") {
        ele.style.display = "block";
    }


}

function closeaddVideofield() {
    var ele = document.getElementById("addVideofield");
    if (ele.style.display == "block") {
        ele.style.display = "none";
    }

    var ele = document.getElementById("av");
    if (ele.style.display == "block") {
        ele.style.display = "none";
    }
    var ele = document.getElementById("nv");
    if (ele.style.display == "none") {
        ele.style.display = "block";
    }

    var ele = document.getElementById("maskV");
    if (ele.style.display == "block") {
        ele.style.display = "none";
    }
    var ele = document.getElementById("maskV2");
    if (ele.style.display == "block") {
        ele.style.display = "none";
    }


    var ele = document.getElementById("norA");
    if (ele.style.display == "none") {
        ele.style.display = "block";
    }
    var ele = document.getElementById("actA");
    if (ele.style.display == "block") {
        ele.style.display = "none";
    }

}


function InitJQuery() {

    //comments functionality

    $("p[pstat='hdn']").hide();
    $("div[ctoshowhide='y']").slideUp();

    $("div.CommentsWrap div.Comments a").click(function (e) {
        $(this).parents("div.Cwrapper").find("div[ctoshowhide='y']").slideToggle("slow");
        $("p[pstat='vis']").toggle();
        $("p[pstat='hdn']").toggle();
        e.preventDefault();
    });


    //till here comments functionality

    //this is for groupcomments li block
    $(".incUserDet li").live('click', function (e) {
        e.preventDefault;
        // $(this).css("color", "red");
        var str = $(this).attr('title');
        var sVal = $(this).attr('iVal');
        $("#groupComment" + sVal).val("@" + str);
        $("#groupListMem" + sVal).hide();
        $("#groupComment" + sVal).focus();
    });

    $(".doingTextC").keyup(function () {
        var wchComm = $(this).attr('id');
        var iVal = $(this).attr('idVal');
        var strUser = $(this).val();
        if ((strUser == '') || (strUser == 'null')) {
            $("#groupListMem" + iVal).hide();
            $("#" + wchComm).focus();
        }

        if ((strUser.match('@')) || (strUser.match(' @'))) {
            if (($(this).val()).length > 1) {
                var string = 'iv=' + iVal + '&a=grp&un=' + $(this).val();
                $.ajax({
                    type: "POST",
                    url: "/AutoNames.aspx",
                    data: string,
                    success: function (respMsg) {
                        if (respMsg != '0') {
                            var divClassName = "";
                            divClassName = "groupListMem" + iVal;
                            document.getElementById('groupListMem' + iVal).style.display = "block";
                            if ($("#" + divClassName).text() != '') {
                                $("#" + divClassName).text('');
                                $("#" + divClassName).append(respMsg);
                            } else {
                                $("#" + divClassName).append(respMsg);
                            }
                        } else {
                            $("#groupListMem" + iVal).hide();
                            $("#" + wchComm).focus();
                        }

                    }
                });
            }
        }
    });

    //end here this is for groupcomments li block

    $("#userNamesList li").live('click', function (e) {
        e.preventDefault;
        // $(this).css("color", "red");
        var str = $(this).attr('title');
        $("#doingText").val("@" + str);
        $("#userNamesList").hide();
        $("#doingText").focus();
    });

    $("#doingText").keyup(function () {
        var strUser = $(this).val();
        if ((strUser == '') || (strUser == 'null')) {
            $("#userNamesList").hide();
            $("#doingText").focus();
        }

        if ((strUser.match('@')) || (strUser.match(' @'))) {
            if (($(this).val()).length > 1) {
                var string = 'a=c&un=' + $(this).val();
                $.ajax({
                    type: "POST",
                    url: "/AutoNames.aspx",
                    data: string,
                    success: function (respMsg) {
                        if (respMsg != '0') {
                            var divClassName = "";
                            divClassName = "userNamesList";
                            document.getElementById('userNamesList').style.display = "block";
                            if ($("#" + divClassName).text() != '') {
                                $("#" + divClassName).text('');
                                $("#" + divClassName).append(respMsg);
                            } else {
                                $("#" + divClassName).append(respMsg);
                            }
                        } else {
                            $("#userNamesList").hide();
                            $("#doingText").focus();
                        }

                    }
                });
            }
        }
    });

    $("div.addPic").click(function () {
        if (!($("div.addPic").find("div.AddPhotoOptions").is(':visible'))) {
            $("div.addPic").find("div.AddPhotoOptions").fadeIn('fast');
            setTimeout("boolWallClicked1 = true;", 1000);
        } else
            $("div.addPic").find("div.AddPhotoOptions").fadeOut('fast');
    });


    $("#resUpdDlg").dialog({
        position: ['center', 'top'],
        autoOpen: false,
        modal: true,
        minWidth: 580,
        minHeight: 270
    });


    $('.ui-widget-overlay').live("click", function () {
        //Close the dialog
        document.getElementById('edtUpdDlg').innerHTML = '';
        $("#resUpdDlg").dialog("close");
        $("#ShareUpdDlg").dialog("close");
    });


    $("#edtUpdDlg").dialog({
        position: ['center', 'middle'],
        autoOpen: false,
        modal: true,
        minWidth: 580,
        minHeight: 270
    });


    $("#ShareUpdDlg").dialog({
        position: ['center', 'middle'],
        autoOpen: false,
        modal: true,
        minWidth: 580,
        minHeight: 270
    });


    $("textarea.doingText").focus(function () {
        $(this).height("45px");
    });

    $("textarea.doingTextC").focus(function () {
        $(this).height("26px");

    });
    initEmbedly();
}


function deleteArt(artId, logo, sub, i) {
    if (confirm("Are you sure you want to delete article " + sub + "?")) {
        $('#load').fadeIn();
        var commentContainer = $("#" + i);
        var string = 'memberId=' + artId + '&a=delArt&logo=' + logo;
        $.ajax({
            type: "POST",
            url: "/WorkUsingJquery.aspx",
            data: string,
            cache: false,
            success: function () {
                commentContainer.slideUp('slow', function () { $("#" + i).remove(); });
                $('#load').fadeOut();
                $("div#result").css("display", "block");
                $("div#result").text("Article " + sub + " has been deleted successfully.");
            }
        });
        return false;
    }
    return false;
}

function deleteNote(artId, logo, sub, i) {
    if (confirm("Are you sure you want to delete note " + sub + "?")) {
        $('#load').fadeIn();
        var commentContainer = $("#" + i);
        var string = 'memberId=' + artId + '&a=delNote&logo=' + logo;

        $.ajax({
            type: "POST",
            url: "/WorkUsingJquery.aspx",
            data: string,
            cache: false,
            success: function () {
                commentContainer.slideUp('slow', function () { $("#" + i).remove(); });
                $('#load').fadeOut();
            }
        });
        return false;
    }
    return false;
}
function openaddLink() {

    var ele = document.getElementById("addLinkfield");
    if (ele.style.display == "none") {
        ele.style.display = "block";
    }
    var ele = document.getElementById("maskL");
    if (ele.style.display == "none") {
        ele.style.display = "block";
    }

    var ele = document.getElementById("ShareControls");
    if (ele.style.display == "none") {
        ele.style.display = "block";
    }

    var ele = document.getElementById("nl");
    if (ele.style.display == "block") {
        ele.style.display = "none";
    }
    var ele = document.getElementById("al");
    if (ele.style.display == "none") {
        ele.style.display = "block";
    }

    var ele = document.getElementById("norA");
    if (ele.style.display == "block") {
        ele.style.display = "none";
    }
    var ele = document.getElementById("actA");
    if (ele.style.display == "none") {
        ele.style.display = "block";
    }

}

function closeaddLink() {
    var ele = document.getElementById("addLinkfield");
    if (ele.style.display == "block") {
        ele.style.display = "none";
    }
    var ele = document.getElementById("maskL");
    if (ele.style.display == "block") {
        ele.style.display = "none";
    }

    var ele = document.getElementById("nl");
    if (ele.style.display == "none") {
        ele.style.display = "block";
    }
    var ele = document.getElementById("al");
    if (ele.style.display == "block") {
        ele.style.display = "none";
    }

    var ele = document.getElementById("norA");
    if (ele.style.display == "none") {
        ele.style.display = "block";
    }
    var ele = document.getElementById("actA");
    if (ele.style.display == "block") {
        ele.style.display = "none";
    }

}

function showLinkPreview() {

    var ele = document.getElementById("norA");
    if (ele.style.display == "none") {
        ele.style.display = "block";
    }
    var ele = document.getElementById("actA");
    if (ele.style.display == "block") {
        ele.style.display = "none";
    }
}

function hideLinkPreview() {
    var ele = document.getElementById("LinkPreview");
    if (ele.style.display == "block") {
        ele.style.display = "none";
    }
    var ele = document.getElementById("maskL");
    if (ele.style.display == "block") {
        ele.style.display = "none";
    }
    var ele = document.getElementById("nl");
    if (ele.style.display == "none") {
        ele.style.display = "block";
    }
    var ele = document.getElementById("al");
    if (ele.style.display == "block") {
        ele.style.display = "none";
    }
    var ele = document.getElementById("norA");
    if (ele.style.display == "none") {
        ele.style.display = "block";
    }
    var ele = document.getElementById("actA");
    if (ele.style.display == "block") {
        ele.style.display = "none";
    }
    document.getElementById('urlLnk').value = '';
}

var boolWallClicked1 = false;

$(document).ready(function () {
    $(document).click(function () {
        //// Hdiging the Photo Upload Div
        if ($("div.addPic").find("div.AddPhotoOptions").is(':visible')) {

            if (boolWallClicked1) {
                $("div.addPic").find("div.AddPhotoOptions").fadeOut('fast');
                boolWallClicked1 = false;
            }
        } else
            boolWallClicked1 = false;
        ////Hiding Photo Upload Div

        if ((!isClickHandled) && $(".acc-panel").is(':visible'))
            $(".acc-panel").fadeOut('fast');
        isClickHandled = false;
    });

    $(".acc-settings").click(function () {
        if (!($(".acc-panel").is(':visible'))) {
            $(".acc-panel").fadeIn('fast');
            isClickHandled = true;
        }
    });

    $(".acc-panel").click(function () { isClickHandled = true; });

    $("ul.subnav").parent().append("<span></span>"); //Only shows drop down trigger when js is enabled - Adds empty span tag after ul.subnav

    $("ul.topnav li span").click(function () { //When trigger is clicked...

        //Following events are applied to the subnav itself (moving subnav up and down)
        $(this).parent().find("ul.subnav").slideDown('fast').show(); //Drop down the subnav on click

        $(this).parent().hover(function () {
        }, function () {
            $(this).parent().find("ul.subnav").slideUp('slow'); //When the mouse hovers out of the subnav, move it back up
        });

        //Following events are applied to the trigger (Hover events for the trigger)
    }).hover(function () {
        $(this).addClass("subhover"); //On hover over, add class "subhover"
    }, function () { //On Hover Out
        $(this).removeClass("subhover"); //On hover out, remove class "subhover"
    });
});

function pageLoad(sender, args) {
    // $(body).removeClass().addClass("yui-skin-sam ARscroll Themes <%=themeClr%>");

    $(".tipped").each(function () {
        Tipped.create(this, "/AutoNames.aspx", {
            type: "post",
            cache: true,
            ajax: {
                data: { a: $(this).attr("tipP"), mId: $(this).attr("mId") }
            }
        });
    });

    $('select#speedC').selectmenu();

    if (jQuery) {
        if ($("div.msg_list").children("div.msg_body").children("div.commentpost").length > 3) {
            $("div.msg_list").children("div.msg_body").children("div.commentpost").hide();
            $("div.msg_list").children("div.msg_body").children("div.commentpost:nth-child(1)").show();
            $("div.msg_list").children("div.msg_body").children("div.commentpost:nth-child(2)").show();
            $("div.msg_list").children("div.msg_body").children("div.commentpost:nth-child(3)").show();

            $("div.msg_list").children("span.msg_head").click(function (ev) {
                $(this).parent().find("div.msg_body").children("div.commentpost:hidden").slideDown("slow");
                $(this).slideUp("slow", function () { $(this).remove(); });
            });
        }
    }

    $("#tokenize2").tokenInput("cntFriends.aspx", {
        classes: {
            tokenList: "token-input-list-facebook",
            token: "token-input-token-facebook",
            tokenDelete: "token-input-delete-token-facebook",
            selectedToken: "token-input-selected-token-facebook",
            highlightedToken: "token-input-highlighted-token-facebook",
            dropdown: "token-input-dropdown-facebook",
            dropdownItem: "token-input-dropdown-item-facebook",
            dropdownItem2: "token-input-dropdown-item2-facebook",
            selectedDropdownItem: "token-input-selected-dropdown-item-facebook",
            inputToken: "token-input-input-token-facebook"
        }
    });

    $("#showToPeople").tokenInput("cntFriends.aspx", {
        classes: {
            tokenList: "token-input-list-facebook",
            token: "token-input-token-facebook",
            tokenDelete: "token-input-delete-token-facebook",
            selectedToken: "token-input-selected-token-facebook",
            highlightedToken: "token-input-highlighted-token-facebook",
            dropdown: "token-input-dropdown-facebook",
            dropdownItem: "token-input-dropdown-item-facebook",
            dropdownItem2: "token-input-dropdown-item2-facebook",
            selectedDropdownItem: "token-input-selected-dropdown-item-facebook",
            inputToken: "token-input-input-token-facebook"
        }
    });

    InitJQuery();

}

//a custom format option callback
var addressFormatting = function (text) {
    var newText = text;
    //array of find replaces
    var findreps = [
        { find: /^([^\-]+) \- /g, rep: '<span class="ui-selectmenu-item-header">$1</span>' },
        { find: /([^\|><]+) \| /g, rep: '<span class="ui-selectmenu-item-content">$1</span>' },
        { find: /([^\|><\(\)]+) (\()/g, rep: '<span class="ui-selectmenu-item-content">$1</span>$2' },
        { find: /([^\|><\(\)]+)$/g, rep: '<span class="ui-selectmenu-item-content">$1</span>' },
        { find: /(\([^\|><]+\))$/g, rep: '<span class="ui-selectmenu-item-footer">$1</span>' }
    ];

    for (var i in findreps) {
        newText = newText.replace(findreps[i].find, findreps[i].rep);
    }
    return newText;
};

$(document).ready(function () {
    $(".ui-dialog-titlebar-close").click(function () {
        document.getElementById('edtUpdDlg').innerHTML = '';
        $("#edtUpdDlg").dialog("close");
    });

    $('li.rollNoti').live('click', function () {
        window.location = "/Notifications.aspx";
    });

});

$(document).ready(function () {
    $("#name").keyup(function () {
        var string = 'un=' + $(this).val();
        $.ajax({
            type: "POST",
            url: "/AutoNames.aspx",
            data: string,
            success: function (respMsg) {
                var divClassName = "";
                divClassName = "searchGet";
                if ($("#" + divClassName).text() != '') {
                    $("#" + divClassName).text('');
                    $("#" + divClassName).append(respMsg);
                } else {
                    $("#" + divClassName).append(respMsg);
                }

            }
        });

    });

});

var boolHideRemoveOptions = false;

function openremoveOptions(ig) {
    var ele = document.getElementById("removeOptions" + ig);
    if (ele.style.display == "none") {
        ele.style.display = "block";
        boolHideRemoveOptions = true;
    }
}

function closeremoveOptions(ig) {
    var ele = document.getElementById("removeOptions" + ig);
    if (ele.style.display == "block") {
        ele.style.display = "none";
    }
}


var boolWallClicked = false;
$(document).ready(function () {
    $(document).click(function () {

        $("#userNamesList").hide(); //for out click in usernames list in status giving box
        $(".incUserDet").hide(); //for out click of group comments drop down block

        $("#searchGet").find(".searchresults-popup").hide();

        //from here RemoveOptions hiding handling
        if (boolHideRemoveOptions)
            $("div.removeOptions").hide();

        if ((!boolWallClicked) && ($("div#searchGet").find("div.searchresults-popup").is(':visible')))
            $("div#searchGet").find("div.searchresults-popup").hide();


        if ((!boolWallClicked) && ($("div.wall").find("div.notifications-popup").is(':visible')))
            $("div.wall").find("div.notifications-popup").hide();

        boolWallClicked = false;
    });

    //Notifications
    $("div.wall").click(function () {
        if (!($("div.wall").find("div.notifications-popup").is(':visible'))) {
            $("div.wall").find("div.notifications-popup").fadeIn('fast');
            boolWallClicked = true;
        } else
            $("div.wall").find("div.notifications-popup").fadeOut('fast');
    });
});

var isClickHandled = false;
$(document).ready(function () {
    //For members setting block.


    $("textarea.doingText").focus(function () {
        $(this).height("45px");
    });

    $("textarea.doingTextC").focus(function () {
        $(this).height("26px");

    });

    chkLatestUpdates = setTimeout("fnCheckForLatestUpdates()", 20000);
    chkInboxMsgs = setTimeout("fnCheckForInboxMsgs()", 20000);
    chkNotifications = setTimeout("fnCheckForNotification()", 20000);
    chkStats = setTimeout("fnCheckForStats()", 20000);


});

$(document).ready(function () {
    var isClickHandled = false;

    $(document).click(function () {
        if ((!isClickHandled) && $(".myMenu").is(':visible'))
            $(".subnav").fadeOut('fast');
        isClickHandled = false;
    });

    $(".myMenu").click(function () {
        if (!($(".subnav").is(':visible'))) {
            $(".subnav").fadeIn('fast');
            isClickHandled = true;
        }
    });

    $(".subnav").click(function () { isClickHandled = true; });
    //login ends
});

$(document).ready(function () {
    var isClickHandled = false;

    $(document).click(function () {
        if ((!isClickHandled) && $(".themes").is(':visible'))
            $(".themes-popup").fadeOut('fast');
        isClickHandled = false;
    });

    $(".themes").click(function () {
        if (!($(".themes-popup").is(':visible'))) {
            $(".themes-popup").fadeIn('fast');
            isClickHandled = true;
        }
    });

    $(".themes-popup").click(function () { isClickHandled = true; });
    //login ends
});